<template>
  <div>
    <group title="发送消息">
      <x-input placeholder="消息标题"></x-input>
      <x-textarea :max="200" v-model="content" name="description" placeholder="消息内容" :height="200" :rows="8" :cols="30"></x-textarea>
      <cell title="发送对象" is-link link="/SendToUserList">共{{getSendToUserList.length}}个</cell>
      <x-button type="warn">预览</x-button>
      <x-button type="primary" @click.native="sendMsg" >发送</x-button>
    </group>
  </div>
</template>
<script>
  import { XTextarea, Group, XInput, XButton, Cell } from 'vux'
  import {mapGetters} from 'vuex'
  export default {
    components: {
      XTextarea,
      Group,
      XInput,
      XButton,
      Cell
    },
    computed: mapGetters([
      'getSendToUserList'
    ]),
    created: function () {
    },
    methods: {
      sendMsg () {
        this.getSendToUserList.forEach((value, index, array) => {
          let userName = value.wxName
          userName = userName.substring(userName.indexOf('(') + 1, userName.indexOf(')'))
          this.$http.post('/wx/WxRobotController.do?sendWxMsgByRemarkName',
            {'uuid': localStorage.uuid, 'content': this.content, 'sendToUser': userName})
        .then(function (res) {
          console.log(res)
        })
        })
      }
    },
    data () {
      return {
        content: ''
      }
    }
  }
</script>

<style scoped>

</style>
